var BSTMG = BSTMG || {};
BSTMG.companyEmplListManager = {
	init: function(){
		var that = this;
		//分页功能
		that.selectCompanyEmplList();
	},
	selectCompanyEmplList: function(){
		var userId = $('#userId').val();
		BSTMG.common.hjhPages("/userAdmin/companyEmplList",{userId:userId},function(data){
			var empList = data.empList;
			var $tbody = $("#companyEmpList tbody");
			var $tr = '';
			if(empList.length > 0) {
				for(var i=0;i<empList.length;i++){
					var empInfo = empList[i];
					var loginNum = setLoginNum(empInfo);
					var accountMoney = setAccountMoney(empInfo);
					$tr += '<tr class="odd">';
					$tr += '<td>'+(i+1)+'</td>';
					$tr += '<td>'+checkNull(loginNum)+'</td>';
					$tr += '<td>'+checkNull(empInfo.phone)+'</td>';
					$tr += '<td>'+parseFloat(accountMoney).toFixed(2)+'元</td>';
					$tr += '<td>'+checkNull(empInfo.virtualPhone)+'</td>';
					$tr += '<td>'+checkNull(empInfo.realName)+'</td>';
					$tr += '<td><a class="btn btn-primary" href="/userAdmin/companyDetail/'+empInfo.userId+'">查看详情</a>';
					$tr += '</td></tr>';
				}
				$tbody.html($tr);
			}else {
				var $tr = '<tr class="odd"><td colspan="7">暂无数据！</td></tr>';
				$tbody.html($tr);
				alert("查询失败！")
			}
		});
	}
}

$(function(){
	BSTMG.companyEmplListManager.init();
});

//检测非空
function checkNull(para){
	if(para == null){
		return "";
	}else{
		return para;
	}
}

//设置登陆账号
function setLoginNum(empInfo){
	if(empInfo.userEmail != "" && empInfo.userEmail != null){
		return empInfo.userEmail;
	}else if(empInfo.userTel != "" && empInfo.userTel != null){
		return empInfo.userTel;
	}else{
		return "";
	}
}

function setAccountMoney(empInfo){
	if(empInfo.accountMoney != "" && empInfo.accountMoney != null){
		return empInfo.accountMoney;
	}else{
		return 0.00;
	}
}


